<div class="content-table">
    <h2><?php echo $this->titulo; ?></h2>
    <div id="container" class="cnt_list_gl">
    <?php 
        foreach ($this->result as $row) {
            $img = 'public/upload/'.$this->controller.'/'.$row->GAL_ID.'.*';
            foreach (glob($img) as $src) {
                
                if($row->GAL_TAM == 'N') $item = 'pqn';//$tam = 196;
                else $item = 'gnd';//$tam = 394;
                ?>
                <div id="cnt_gl_<?php echo $row->GAL_ID; ?>" class="cnt_gl item <?php echo $item;?>">
                    <div class="cnt_btn">
                        <ul class="ui-widget ui-helper-clearfix">
                            <li title="Editar" class="ui-state-highlight ui-corner-all edt_foto" id="<?php echo $row->GAL_ID; ?>" tam="<?php echo $row->GAL_TAM; ?>"><span class="ui-icon ui-icon-wrench"></span></li>
                            <li title="Excluir" class="ui-state-error ui-corner-all del_foto" id="<?php echo $row->GAL_ID; ?>"><span class="ui-icon ui-icon-closethick"></span></li>
                        </ul>
                    </div>
                <?php echo '<a href="'.$this->urlbase.'/'.$src.'" data-lightbox="roadtrip" /><img title="'.$row->GAL_NOM.'" src="'.$this->urlbase.'/'.str_replace('.', '_tb.',$src).'" /></a>'; ?>
                </div>
                <?php
            }
        }
    ?>
    </div>
    <form method="post" action="" enctype="multipart/form-data">
        <table id="tlist" class="tb_content">
            <tr> 
                <td colspan="2" class="tl-gl-ft">Adicionar Fotos</td>
            </tr>
            <tr>  
                <td width="40" style="height: 50px;"><input type="text" name="titulo" value="" placeholder="Título da Foto" /></td>
                <td>
                    <label><input type="radio" name="tamanho" value="N" checked="" /> Foto Normal</label>
                    &nbsp;&nbsp;
                    <label><input type="radio" name="tamanho" value="D" /> Foto Destaque</label>
                </td>
                
            </tr>
            <tr> 
                <td style="height: 50px;">
                    <input type="file" name="imagem" placeholder="Foto" />
                    <input id="fileupload" type="file" name="files[]" multiple>
                </td>
                <td><input type="submit" class="btn-button btn-camera" value="Enviar" id="submitbutton" name="submit"></td>
            </tr>
        </table>
    </form>
</div>
<div id="dialog"></div>

<script src="<?php echo $this->urlbase.'/public/media/js/masonry.pkgd.min.js'?>"></script>
<script> 
$(function(){

    //var container = document.querySelector('#container');
    //var msnry = new Masonry( container, {
    $('#container').masonry({
      itemSelector: '.item',
      columnWidth: 1
    });
    
    
}); 
</script>


<link  href="<?php echo $this->urlbase.'/public/media/js/lightbox/css/lightbox.css' ?>" rel="stylesheet" media="screen"/>
<script src="<?php echo $this->urlbase.'/public/media/js/lightbox/js/modernizr.custom.js' ?>"></script>
<script src="<?php echo $this->urlbase.'/public/media/js/lightbox/js/lightbox-2.6.min.js' ?>"></script>


<script src="<?php echo $this->urlbase.'/public/media/js/multiupload/'; ?>js/vendor/jquery.ui.widget.js"></script>
<script src="<?php echo $this->urlbase.'/public/media/js/multiupload/'; ?>js/jquery.iframe-transport.js"></script>
<script src="<?php echo $this->urlbase.'/public/media/js/multiupload/'; ?>js/jquery.fileupload.js"></script>
<script>
$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = '<?php echo $this->urlbase.'/public/media/js/multiupload/server/php/'; ?>';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo('#files');
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>